//
//  GoodandpedView.m
//  FoodFamily
//
//  Created by dlios on 15-6-22.
//  Copyright (c) 2015年 guoBang. All rights reserved.
//

#import "GoodandpedView.h"

@implementation GoodandpedView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {

            }
    return self;
}


-(void)qwer
{
    self.quanpingscrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-20-44-49)];
    if (WIDTH< 375) {
        self.quanpingscrollview.contentSize = CGSizeMake(0, HEIGHT);
    }
    
    // self.quanpingscrollview.pagingEnabled = YES;//按页翻
    self.quanpingscrollview.bounces = NO;//禁止边界反弹效果
    self.quanpingscrollview.showsHorizontalScrollIndicator = YES;//隐藏横向水平滑动条
    self.quanpingscrollview.showsVerticalScrollIndicator = NO;//隐藏纵向滑动条
    self.quanpingscrollview.backgroundColor = [UIColor clearColor];
    //返回顶部
    self.quanpingscrollview.scrollsToTop = YES;
    [self addSubview:self.quanpingscrollview];
    
#pragma 上面图片  左右
    
    UIImageView *vie = [[UIImageView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    vie.image = [UIImage imageNamed:@"beijing.png"];
    [self.quanpingscrollview addSubview:vie];
    
    
    UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(10*COEFFICIENTW, 20, 50*COEFFICIENTH, 50)];
    imageview.image = [UIImage imageNamed:@"yi.png"];
    [self.quanpingscrollview addSubview:imageview];
    
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(70*COEFFICIENTW, 20, 300*COEFFICIENTH, 25)];
    label1.text = @"FIT FOOD & EFFICIENCY";
    label1.backgroundColor = [UIColor clearColor];
    label1.textColor = [UIColor darkTextColor];
    [self.quanpingscrollview addSubview:label1];
    
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(70*COEFFICIENTW, 45,300*COEFFICIENTH, 25)];
    label2.text = @"相宜食物搭配及功效";
    label2.textColor = [UIColor colorWithRed:45/255.0 green:112/255.0 blue:0 alpha:1];
    [self.quanpingscrollview addSubview:label2];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(135*COEFFICIENTW, 75, 210*COEFFICIENTH, 190)];
    view.backgroundColor = [UIColor colorWithRed:45/255.0 green:112/255.0 blue:0 alpha:1];
    [self.quanpingscrollview addSubview:view];
    
    self.scrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(140*COEFFICIENTW, 80, 200*COEFFICIENTH, 180)];
         _scrollview.contentSize = CGSizeMake(200*self.fittingarray.count, 150);
    [self.quanpingscrollview addSubview:self.scrollview];
    self.scrollview.pagingEnabled = YES;//按页翻
    self.scrollview.bounces = NO;//禁止边界反弹效果
    self.scrollview.showsHorizontalScrollIndicator = YES;//隐藏横向水平滑动条
    self.scrollview.showsVerticalScrollIndicator = NO;//隐藏纵向滑动条
    //返回顶部
    self.scrollview.scrollsToTop = YES;
    

    //NSLog(@"1111111");
    self.imageview = [[UIImageView alloc]initWithFrame:CGRectMake(10*COEFFICIENTW, 80, 100*COEFFICIENTH, 100)];
    self.imageview.backgroundColor = [UIColor clearColor];
    [self.quanpingscrollview addSubview:self.imageview];
    //NSLog(@"222222");
#pragma 下面图片  左右
//    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(10, 290, 50, 50)];
//    label3.text = @"克";
//    label3.textColor = [UIColor whiteColor];
//    label3.backgroundColor = [UIColor purpleColor];
//    label3.font = [UIFont systemFontOfSize:25];
//    label3.textAlignment = NSTextAlignmentCenter;
//    label3.layer.masksToBounds = YES;
//    label3.layer.cornerRadius = 25;
//    [self addSubview:label3];
    UIImageView *imageview1 = [[UIImageView alloc]initWithFrame:CGRectMake(10*COEFFICIENTW, 290, 50*COEFFICIENTH, 50)];
    imageview1.image = [UIImage imageNamed:@"xiangke.png"];
    [self.quanpingscrollview addSubview:imageview1];
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(70*COEFFICIENTW, 290, 300*COEFFICIENTH, 25)];
    label4.text = @"TABOO FOOD & CONSEQUENCE";
    label4.textColor = [UIColor darkTextColor];
    [self.quanpingscrollview addSubview:label4];
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(70*COEFFICIENTW, 315, 300*COEFFICIENTH, 25)];
    label5.textColor = [UIColor colorWithRed:101/255.0 green:48/255.0 blue:2/255.0 alpha:1];
    label5.text = @"相忌食物搭配及后果";
    [self.quanpingscrollview addSubview:label5];
    
    
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(135*COEFFICIENTW, 355, 210*COEFFICIENTH, 190)];
    view1.backgroundColor = [UIColor colorWithRed:101/255.0 green:48/255.0 blue:2/255.0 alpha:1];
   
    [self.quanpingscrollview addSubview:view1];
    self.scrollview1 = [[UIScrollView alloc]initWithFrame:CGRectMake(140*COEFFICIENTW, 360, 200*COEFFICIENTH, 180)];
    self.scrollview1.contentSize = CGSizeMake(200*self.gramarray.count, 0);
    self.scrollview1.backgroundColor = [UIColor clearColor];
    [self.quanpingscrollview addSubview:self.scrollview1];
    self.scrollview1.pagingEnabled = YES;//按页翻
    self.scrollview1.bounces = NO;//禁止边界反弹效果
    self.scrollview1.showsHorizontalScrollIndicator = YES;//隐藏横向水平滑动条
    self.scrollview1.showsVerticalScrollIndicator = NO;//隐藏纵向滑动条
    //返回顶部
    self.scrollview1.scrollsToTop = YES;
    //NSLog(@"3333333");
//    self.myimageview1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 150)];
//    self.myimageview1.backgroundColor = [UIColor purpleColor];
//    [self.scrollview1 addSubview:self.myimageview1];
   // NSLog(@"4444444");
    self.imageview1 = [[UIImageView alloc]initWithFrame:CGRectMake(10*COEFFICIENTW, 360, 100*COEFFICIENTH, 100)];
    self.imageview1.backgroundColor = [UIColor clearColor];
    [self.quanpingscrollview addSubview:self.imageview1];
#pragma 左上
    Movie *movie = [self.gooarray firstObject];
    NSURL *url = [NSURL URLWithString:movie.imageName];
    [self.imageview sd_setImageWithURL:url];
    
    self.materialName = [[UILabel alloc]initWithFrame:CGRectMake(10*COEFFICIENTW, 190, 100*COEFFICIENTH, 20)];
    self.materialName.backgroundColor = [UIColor clearColor];
    self.materialName.text = movie.materialName;
    [self.quanpingscrollview addSubview:self.materialName];
      // NSLog(@"5555555");
#pragma 左下
        NSURL *url1 = [NSURL URLWithString:movie.imageName];
    [self.imageview1 sd_setImageWithURL:url1];
    self.materiaxia = [[UILabel alloc]initWithFrame:CGRectMake(10*COEFFICIENTW, 470, 100*COEFFICIENTH, 20)];
    self.materiaxia.backgroundColor = [UIColor clearColor];
    self.materiaxia.text = movie.materialName;
    [self.quanpingscrollview addSubview:self.materiaxia];

    
#pragma 右上
    //NSLog(@"self.fittingarray.count = %@", self.fittingarray);

    for (int i = 0; i <self.fittingarray.count; i++) {
       
        UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(200*i*COEFFICIENTW, 0, self.scrollview.frame.size.width, self.scrollview.frame.size.height)];
       // NSLog(@"******%@",NSStringFromCGSize(imageview.frame.size));
        imageview.userInteractionEnabled = YES;
        imageview.backgroundColor = [UIColor purpleColor];
        Movie *movie = [  self.fittingarray objectAtIndex:i];
        NSURL *url = [NSURL URLWithString:movie.imageName];
        [imageview sd_setImageWithURL:url];
        [self.scrollview addSubview:imageview];
#pragma imageview上图食物名字
        self.materialName1 = [[UILabel alloc]initWithFrame:CGRectMake(3*COEFFICIENTW,125, 100*COEFFICIENTH, 25)];
        self.materialName1.backgroundColor = [UIColor clearColor];
        self.materialName1.text = movie.materialName;
        self.materialName1.font = [UIFont systemFontOfSize:15];
        [imageview addSubview:self.materialName1];
        #pragma imageview上图食物宜
        self.contentDescription1 = [[UILabel alloc]initWithFrame:CGRectMake(3*COEFFICIENTW, 150, 200*COEFFICIENTH, 25)];
        self.contentDescription1.backgroundColor = [UIColor clearColor];
        self.contentDescription1.text = movie.contentDescription1;
          self.contentDescription1.font = [UIFont systemFontOfSize:12];
        //NSLog(@"movie.contentDescription1 =%@",movie.contentDescription1);
        [imageview addSubview:self.contentDescription1];
    }
    if (WIDTH<375 || WIDTH > 375) {
        
     _scrollview.contentSize = CGSizeMake(200*self.fittingarray.count*COEFFICIENTW, 0);
    }
    
   
#pragma 右下
    if (self.gramarray.count ==0) {
        view1.backgroundColor = [UIColor clearColor];
    }
    for (int i = 0; i <self.gramarray.count; i++) {
        //NSLog(@"*/*/*%ld",self.gramarray.count);
        UIImageView *imagevi = [[UIImageView alloc]initWithFrame:CGRectMake(200*i*COEFFICIENTW, 0,200*COEFFICIENTH, 180)];
        

        Movie *movie = [self.gramarray objectAtIndex:i];
        imagevi.userInteractionEnabled = YES;
        NSURL *url = [NSURL URLWithString:movie.imageName];
        [imagevi sd_setImageWithURL:url];
        [self.scrollview1 addSubview:imagevi];
        //NSLog(@"movie.contentDescription1movie.contentDescription1%@",movie.contentDescription1);
        [self.scrollview1 addSubview:imagevi];
#pragma imageview上图食物名字
        self.materialName1 = [[UILabel alloc]initWithFrame:CGRectMake(3*COEFFICIENTW,125, 100*COEFFICIENTH, 25)];
        self.materialName1.backgroundColor = [UIColor clearColor];
        self.materialName1.text = movie.materialName;
        self.materialName1.font = [UIFont systemFontOfSize:15];
        [imagevi addSubview:self.materialName1];
#pragma imageview上图食物害处
        self.contentDescription1 = [[UILabel alloc]initWithFrame:CGRectMake(3*COEFFICIENTW, 150, 200*COEFFICIENTH, 25)];
        self.contentDescription1.backgroundColor = [UIColor clearColor];
        self.contentDescription1.text = movie.contentDescription1;
        self.contentDescription1.font = [UIFont systemFontOfSize:12];
        //NSLog(@"movie.contentDescription1 =%@",movie.contentDescription1);
        [imagevi addSubview:self.contentDescription1];
        
    }
    if (WIDTH<375 || WIDTH > 375) {
        
    self.scrollview1.contentSize = CGSizeMake(200*self.gramarray.count*COEFFICIENTW, 0);
    }


    

    
  
}
@end
